package com.txcb.lib.base.view.weigit;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.viewpager.widget.ViewPager;

/**
 * @author : Lambert
 * date   : 2020/10/24 9:56 AM
 */
public class MyXViewPager extends ViewPager {

    // 是否禁止 viewpager 左右滑动
      boolean xScroll = true;


    public MyXViewPager(@NonNull Context context) {
        super(context);
    }
    public MyXViewPager(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (xScroll) {
            return false;
        } else {
            return super.onTouchEvent(ev);
        }
    }

    @Override
    public boolean onInterceptTouchEvent(MotionEvent ev) {
        if (xScroll) {
            return false;
        } else {
            return super.onInterceptTouchEvent(ev);
        }
    }
}
